Action hook 'load-{$page_hook}'

in WP Core File wp-admin/admin.php at line 238

View Source

load-{$page_hook}

Action Hook
Description
Fires before a particular screen is loaded. The load-* hook fires in a number of contexts. This hook is for plugin screens where a callback is provided when the screen is registered. The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin page information including: 1. The page type. If the plugin page is registered as a submenu page, such as for Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. 2. A separator of '_page_'. 3. The plugin basename minus the file extension. Together, the three parts form the `$page_hook`. Citing the example above, the hook name used would be 'load-settings_page_pluginbasename'.

Hook Information

File Location wp-admin/admin.php View on GitHub
Hook Type Action
Line Number 238

Hook Parameters

This hook doesn't accept any parameters.

Usage Examples

Basic Usage
<?php
// Hook into load-{$page_hook}
add_action('load-{$page_hook}', 'my_custom_function');

function my_custom_function() {
    // Your custom code here
}

Source Code Context

wp-admin/admin.php:238 - How this hook is used in WordPress core
<?php
 233  		 *
 234  		 * @see get_plugin_page_hook()
 235  		 *
 236  		 * @since 2.1.0
 237  		 */
 238  		do_action( "load-{$page_hook}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 239  		if ( ! isset( $_GET['noheader'] ) ) {
 240  			require_once ABSPATH . 'wp-admin/admin-header.php';
 241  		}
 242  
 243  		/**

PHP Documentation

<?php
/**
		 * Fires before a particular screen is loaded.
		 *
		 * The load-* hook fires in a number of contexts. This hook is for plugin screens
		 * where a callback is provided when the screen is registered.
		 *
		 * The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin
		 * page information including:
		 * 1. The page type. If the plugin page is registered as a submenu page, such as for
		 *    Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'.
		 * 2. A separator of '_page_'.
		 * 3. The plugin basename minus the file extension.
		 *
		 * Together, the three parts form the `$page_hook`. Citing the example above,
		 * the hook name used would be 'load-settings_page_pluginbasename'.
		 *
		 * @see get_plugin_page_hook()
		 *
		 * @since 2.1.0
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 0
  • File: wp-admin/admin.php
Related Hooks

Related hooks will be displayed here in future updates.